/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dailydev.wave.robot.filter;

import java.lang.reflect.Method;
import java.util.List;

import com.google.wave.api.Event;

/**
 * Simple implementation of {@link IFilterManager} which returns same set of
 * {@link IFilter}s for every <code>handler</code>, <code>methodHandler</code>
 * and <code>event</code> combination. The filters to be returned are configured
 * using {@link SimpleFilterManager#setFilters(List<IFilter>)} method.
 * 
 * @author Roman Bosak, DailyDev.org
 */
public class SimpleFilterManager implements IFilterManager {

    /**
     * List of {@link IFilter}s to be applied to before handler method
     * invocation.
     */
    protected List<IFilter> filters;

    /**
     * @param filters
     */
    public SimpleFilterManager() {
    }

    /**
     * @param filters
     */
    public SimpleFilterManager(List<IFilter> filters) {
        this.filters = filters;
    }

    /** {@inheritDoc} */
    @Override
    public List<IFilter> getFiltersToMatch(Object handler, Method handlerMethod, Event event) {
        return filters;
    }

    /**
     * Returns list of {@link IFilter}s configured within this
     * {@link SimpleFilterManager}.
     * 
     * @return the handlerFilters
     */
    public List<IFilter> getFilters() {
        return filters;
    }

    /**
     * Sets list of {@link IFilter}s to be returned by this
     * {@link SimpleFilterManager}.
     * 
     * @param handlerFilters
     *            the handlerFilters to set
     */
    public void setFilters(List<IFilter> handlerFilters) {
        this.filters = handlerFilters;
    }

}
